import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';

import { BlogArticleCard } from '../../class/blog-article-card';
import { BlogService } from '../../service/blog.service';

declare var $: any;

@Component({
  selector: 'app-blog-card',
  templateUrl: './blog-card.component.html',
  styleUrls: ['./blog-card.component.css']
})
export class BlogCardComponent implements OnInit {
  // 博客卡片
  @Input() blogArticleCard: BlogArticleCard;
  // 刷新博客列表
  @Output() refreshBlogList = new EventEmitter<boolean>();

  constructor(private blogService: BlogService) { }

  ngOnInit() { }

  deleteBlogArticle() {
    let bindThis = this;
    bindThis.blogService.deleteArticleById(bindThis.blogArticleCard.articleId, (result) => {
      if (result.code == "200") {
        bindThis.refreshBlogList.emit();
        $("#deleteBlogArticle").modal("hide");
      }
    });
  }
}
